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

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

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

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

g = A("g")
h = B("h")
i = C("i")
f = D("f")
c = C("c")

g.r = i
g.p = i
g.t = f
h.y = i
h.w = f
h.s = g
i.s = g
i.u = h
i.q = c
f.p = c
f.s = c
f.y = g
c.s = g
c.u = h
c.q = i
assert g.t.y.p.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.t: D = None
        self.p: C = None
        self.txt = txt

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

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

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

g = A("g")
h = B("h")
i = C("i")
f = D("f")
c = C("c")

g.r = i
g.p = i
g.t = f
h.y = i
h.w = f
h.s = g
i.s = g
i.u = h
i.q = c
f.p = c
f.s = c
f.y = g
c.s = g
c.u = h
c.q = i
assert g.t.y.p.u.s.txt == "g"