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

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

class C:
    def __init__(self, txt: str):
        self.p: G = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: C = None
        self.p: D = None
        self.u: A = None
        self.o: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: G = None
        self.q: D = None
        self.txt = txt

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

f = A("f")
j = B("j")
m = C("m")
h = D("h")
g = E("g")
b = F("b")
l = G("l")
e = D("e")

f.y = l
j.s = h
j.o = m
m.p = l
h.p = l
h.x = l
g.r = f
g.u = f
g.q = m
g.p = e
g.o = j
b.p = l
b.q = h
l.p = f
e.p = l
e.x = l
assert e.p.p.y.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: G = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: G = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: C = None
        self.p: D = None
        self.u: A = None
        self.o: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: G = None
        self.q: D = None
        self.txt = txt

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

f = A("f")
j = B("j")
m = C("m")
h = D("h")
g = E("g")
b = F("b")
l = G("l")
e = D("e")

f.y = l
j.s = h
j.o = m
m.p = l
h.p = l
h.x = l
g.r = f
g.u = f
g.q = m
g.p = e
g.o = j
b.p = l
b.q = h
l.p = f
e.p = l
e.x = l
assert e.p.p.y.p.y.txt == "l"