class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: D = None
        self.u: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

h = A("h")
i = B("i")
m = C("m")
j = D("j")
c = C("c")
n = C("n")

h.v = i
h.y = i
i.r = c
i.o = j
i.u = j
m.p = i
j.y = h
c.p = i
n.p = i
assert c.p.r.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: D = None
        self.u: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

h = A("h")
i = B("i")
m = C("m")
j = D("j")
c = C("c")
n = C("n")

h.v = i
h.y = i
i.r = c
i.o = j
i.u = j
m.p = i
j.y = h
c.p = i
n.p = i
assert c.p.r.p.u.txt == "j"