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

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

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

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

h = A("h")
a = B("a")
j = C("j")
f = D("f")
e = B("e")
c = C("c")

h.v = e
a.t = e
j.u = e
j.q = f
j.y = h
j.r = a
f.y = e
e.t = a
c.u = e
c.q = f
c.y = h
c.r = a
assert e.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

h = A("h")
a = B("a")
j = C("j")
f = D("f")
e = B("e")
c = C("c")

h.v = e
a.t = e
j.u = e
j.q = f
j.y = h
j.r = a
f.y = e
e.t = a
c.u = e
c.q = f
c.y = h
c.r = a
assert e.t.t.t.txt == "a"