class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.w: A = None
        self.txt = txt

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

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

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

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

f.p = c
f.w = c
b.u = a
b.v = f
e.t = f
e.o = f
a.y = f
a.u = b
a.v = b
a.z = c
c.p = f
c.w = f
n.t = c
n.o = c
j.t = f
j.o = c
assert f.p.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.w: A = None
        self.txt = txt

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

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

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

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

f.p = c
f.w = c
b.u = a
b.v = f
e.t = f
e.o = f
a.y = f
a.u = b
a.v = b
a.z = c
c.p = f
c.w = f
n.t = c
n.o = c
j.t = f
j.o = c
assert f.p.p.w.txt == "c"