class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: B = None
        self.o: A = None
        self.txt = txt

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

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

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

g = A("g")
b = B("b")
k = C("k")
j = D("j")
m = B("m")
c = C("c")
f = A("f")

g.y = f
g.o = f
g.p = b
b.r = f
k.x = j
k.s = c
j.w = m
m.r = g
c.x = j
c.s = k
f.y = g
f.o = g
f.p = b
assert g.p.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: B = None
        self.o: A = None
        self.txt = txt

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

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

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

g = A("g")
b = B("b")
k = C("k")
j = D("j")
m = B("m")
c = C("c")
f = A("f")

g.y = f
g.o = f
g.p = b
b.r = f
k.x = j
k.s = c
j.w = m
m.r = g
c.x = j
c.s = k
f.y = g
f.o = g
f.p = b
assert g.p.r.p.txt == "b"