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

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.p: D = None
        self.w: B = None
        self.v: A = None
        self.txt = txt

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

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

f = A("f")
e = B("e")
l = C("l")
g = D("g")
d = C("d")
c = B("c")

f.y = g
e.u = l
e.p = g
e.w = c
e.v = f
l.y = d
l.x = g
g.t = f
g.r = f
g.y = e
d.y = l
d.x = g
c.u = d
c.p = g
c.w = e
c.v = f
assert l.y.x.r.y.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.p: D = None
        self.w: B = None
        self.v: A = None
        self.txt = txt

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

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

f = A("f")
e = B("e")
l = C("l")
g = D("g")
d = C("d")
c = B("c")

f.y = g
e.u = l
e.p = g
e.w = c
e.v = f
l.y = d
l.x = g
g.t = f
g.r = f
g.y = e
d.y = l
d.x = g
c.u = d
c.p = g
c.w = e
c.v = f
assert l.y.x.r.y.y.p.txt == "g"