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

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

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

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

b = A("b")
n = B("n")
e = C("e")
k = D("k")
f = D("f")
g = A("g")

b.w = n
b.v = n
b.x = n
b.t = g
n.p = f
n.z = k
e.t = g
e.u = f
e.x = k
k.y = g
k.t = e
f.y = g
f.t = e
g.w = n
g.v = n
g.x = n
g.t = b
assert f.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.v: B = None
        self.t: A = None
        self.x: B = None
        self.txt = txt

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

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

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

b = A("b")
n = B("n")
e = C("e")
k = D("k")
f = D("f")
g = A("g")

b.w = n
b.v = n
b.x = n
b.t = g
n.p = f
n.z = k
e.t = g
e.u = f
e.x = k
k.y = g
k.t = e
f.y = g
f.t = e
g.w = n
g.v = n
g.x = n
g.t = b
assert f.t.t.t.t.txt == "g"