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

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

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

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

g = A("g")
l = B("l")
b = C("b")
m = D("m")
j = A("j")
e = C("e")
i = B("i")

g.p = i
g.y = b
g.x = e
l.y = i
b.t = l
b.s = l
m.p = i
j.p = l
j.y = e
j.x = e
e.t = i
e.s = l
i.y = l
assert g.x.t.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: C = None
        self.x: C = None
        self.txt = txt

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

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

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

g = A("g")
l = B("l")
b = C("b")
m = D("m")
j = A("j")
e = C("e")
i = B("i")

g.p = i
g.y = b
g.x = e
l.y = i
b.t = l
b.s = l
m.p = i
j.p = l
j.y = e
j.x = e
e.t = i
e.s = l
i.y = l
assert g.x.t.y.y.y.y.y.txt == "l"