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

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

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

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

c = A("c")
a = B("a")
g = C("g")
f = D("f")

c.r = g
c.w = f
c.o = a
a.o = g
a.z = g
a.y = f
g.u = a
f.r = g
f.y = g
f.p = c
f.w = a
assert a.y.y.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.w: D = None
        self.o: B = None
        self.txt = txt

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

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

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

c = A("c")
a = B("a")
g = C("g")
f = D("f")

c.r = g
c.w = f
c.o = a
a.o = g
a.z = g
a.y = f
g.u = a
f.r = g
f.y = g
f.p = c
f.w = a
assert a.y.y.u.y.txt == "f"