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

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.v: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: B = None
        self.r: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: C = None
        self.v: D = None
        self.txt = txt

b = A("b")
e = B("e")
c = C("c")
h = D("h")
j = C("j")
g = B("g")
k = D("k")

b.r = e
e.t = h
e.v = j
c.z = j
c.v = e
c.r = e
h.q = b
h.t = j
h.v = k
j.z = c
j.v = g
j.r = g
g.t = h
g.v = c
k.q = b
k.t = c
k.v = h
assert c.z.z.v.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.v: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: B = None
        self.r: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: C = None
        self.v: D = None
        self.txt = txt

b = A("b")
e = B("e")
c = C("c")
h = D("h")
j = C("j")
g = B("g")
k = D("k")

b.r = e
e.t = h
e.v = j
c.z = j
c.v = e
c.r = e
h.q = b
h.t = j
h.v = k
j.z = c
j.v = g
j.r = g
g.t = h
g.v = c
k.q = b
k.t = c
k.v = h
assert c.z.z.v.v.z.v.txt == "e"